﻿Module FontMGR
    Private PFC As Drawing.Text.PrivateFontCollection
    Private NewFont_FF As Drawing.FontFamily

    Function CreateFont(ByVal name As String, ByVal style As Drawing.FontStyle, ByVal size As Single, ByVal unit As Drawing.GraphicsUnit) As Drawing.Font
        'Create a new font collection
        PFC = New Drawing.Text.PrivateFontCollection
        'Add the font file to the new font
        '"name" is the qualified path to your font file
        PFC.AddFontFile(name)
        'Retrieve your new font
        NewFont_FF = PFC.Families(0)

        Return New Drawing.Font(NewFont_FF, size, style, unit)
    End Function

    Function CreateFont(ByVal name As String, ByVal size As Single) As Drawing.Font
        'Create a new font collection
        PFC = New Drawing.Text.PrivateFontCollection
        'Add the font file to the new font
        '"name" is the qualified path to your font file
        PFC.AddFontFile(name)
        'Retrieve your new font
        NewFont_FF = PFC.Families(0)

        Return New Drawing.Font(NewFont_FF, size)
    End Function
End Module
